/*
* 一。将下面异步代码使用Promise的方式改进
  * setTimeout(function () {
      var a = 'hello'
      setTimeout(function () {
        var b = 'lagou'
        setTimeout(function () {
          var c = 'I ❤ U'
          console.log(a + b + c)
        },10)
      },10)
    },10)
* */

// 作答
// 使用计数器来判断是否正常异步
let i = 0;
function asyncJoin (str, delay = 10) {
  return new Promise((resolve, reject) => {
    setTimeout(() => {
      i++;
      console.log(i,str);
      resolve(str)
    }, delay)
  });
}
asyncJoin('hello')
    .then(str => asyncJoin(`${str} lagou`))
    .then(str => asyncJoin(`${str} I❤ U`))
    .then(console.log);



